{% extends './base.html' %}
{% block head %}
<title>Search Results</title>
{% endblock %}
{% block content %}
<div class="container-sm">
    <div class="m-2">
    </div>
    <h1>课程搜索结果：</h1>
    {% if lessons %}
    <div class="row row-cols-1 row-cols-md-3 row-cols-lg-4 g-4">
        {% for lesson in lessons %}
        <div class="col">
            <div class="card h-100 shadow-sm">
                <div class="card-header">
                    {{lesson.name}}
                    <small class="text-muted">by {{ lesson.teacher }}</small>
                </div>
                <div class="card-body">
                    <blockquote class="blockquote mb-0" style="padding-bottom: 1rem;">
                        <p style="font-size: small;">
                            {{ lesson.bestcomment.comment }}
                            <footer class="blockquote-footer text-end"> {{ lesson.bestcomment.term }} <cite
                                    title="Source Title">{{ lesson.bestcomment.name }}</cite>
                            </footer>
                    </blockquote>
                </div>
                <div class="d-grid gap-2 d-md-flex justify-content-md-end m-2">
                    <a href="{% url 'lesson:lesson' lesson.id %}" class="btn btn-primary ">查看详情</a>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
    {% else %}
    <h2 class="display-2">No Lessons Found</h2>
    {% endif %}
    <h1 class="mt-3">评论搜索结果：</h1>
    {% if comments %}
    <div class="row row-cols-1 row-cols-md-3 row-cols-lg-4 g-4">
        {% for comment in comments %}
        <div class="col">
            <div class="card h-100 shadow-sm">
                <div class="card-body">
                    <h5 class="card-title">无标题</h5>
                    <h6 class="card-subtitle mb-2 text-muted">{{ comment.name }} 学期:{{ comment.term }}
                        得分:{{ comment.score }}</h6>
                    <p class="card-text">{{ comment.html|safe }}</p>
                </div>
                <div class="card-footer">
                    <small class="text-muted">最后更新于：{{ comment.date }}</small>
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
    {% else %}
    <h2 class="display-2">No Comments Found</h2>
    {% endif %}
</div>
{% endblock %}